/**
 * @Date: 2022-04-07 19:02:35
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-04-21 11:06:43
 * @FilePath: \weibo-api\model\index.js
 * @Description: 模型入口文件
 */
const User = require("./users");
const Blog = require("./Blog");
const UserRelations = require("./UserRelation");
const Topic = require("./Topic");
const Reply = require("./Reply");
const AtRelation = require("./AtRelation");
const AtBlog = require("./AtBlog");
const Like = require("./Like");

Blog.belongsTo(User, {
  foreignKey: "userId",
});
Blog.hasMany(AtBlog, {
  foreignKey: "blogId",
});
Reply.hasMany(AtRelation, {
  foreignKey: "id",
});
Blog.hasMany(Like, {
  foreignKey: "blogId",
});
Like.belongsTo(User, {
  foreignKey: "userId",
});
Blog.hasMany(Topic, {
  foreignKey: "blogId",
});
Topic.belongsTo(Blog, {
  foreignKey: "blogId",
});
User.hasMany(Blog, {
  foreignKey: "userId",
});
User.hasMany(Topic, {
  foreignKey: "userId",
});
Topic.belongsTo(User, {
  foreignKey: "userId",
});
Topic.hasMany(Reply, {
  foreignKey: "commentId",
});
Reply.belongsTo(User, {
  foreignKey: "userId",
});
UserRelations.belongsTo(User, {
  foreignKey: "followerId",
});
User.hasMany(UserRelations, {
  foreignKey: "userId",
});
module.exports = {
  User,
  Blog,
  UserRelations,
  Topic,
  Reply,
  AtRelation,
  AtBlog,
  Like,
};
